import { defineStore } from 'pinia'
export const useUserStore = defineStore('user', {
    state: () => ({
        username: '',
        email: '',
        gender: 'Male',
        userImage: '',  // 存储头像URL
        password: '' // 可以根据需要存储密码
    }),
    actions: {
        // 设置用户信息
        setUserInfo(userData) {
            this.username = userData.username
            this.email = userData.email
            this.gender = userData.gender
            this.userImage = userData.userImage || ''
            this.password = userData.password || ''
        },
        // 更新头像
        updateUserImage(userImage) {
            this.userImage = userImage
        },
        // 更新用户名、邮箱和性别
        updateUserInfo({ username, email, gender }) {
            this.username = username
            this.email = email
            this.gender = gender
        }
    },
    persist: true  // 使用 Pinia 的持久化插件，数据会存储在本地
})
